import QtQuick 2.0
import QtQuick.Controls 1.1

Rectangle{
    width: 400; height: 320
    color: "#121212"

    BusyIndicator{
        id: busy
        running: true
        anchors.centerIn: parent
        z: 2
    }

    Label{
        id: stateLabel
        visible: false
        anchors.centerIn: parent
        z: 3
        color: "white"
    }

    Image {
        id: imageViewer
        asynchronous: true
        cache: true
        anchors.fill: parent
        fillMode: Image.PreserveAspectFit
        onStatusChanged: {
            if (imageViewer.status == Image.Loading){
                busy.running = true
                stateLabel.visible = false
            }else if (imageViewer.status == Image.Ready){
                busy.running = false
            }else if (imageViewer.status == Image.Error){
                busy.running = false
                stateLabel.visible = false
                stateLabel.text = "ERROR"
            }
        }
    }

    Component.onCompleted: {
        imageViewer.source = "http://image.baidu.com/detail/newindex?col=%E6%98%8E%E6%98%9F&tag=%E5%88%98%E8%AF%97%E8%AF%97&pn=0&pid=9520070998&aid=&user_id=36159639&setid=-1&sort=0&ftag1=&ftag2=&from=1"
    }
}

















